<?php
/***********************************************************************

  Copyright (C) 2008  Fabrice douteaud (fdouteaud@gmail.com)

    This file is part of ClearBudget.

    ClearBudget is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ClearBudget is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.


************************************************************************/
// if we have the request to secure the access to the site, we must have a valid username and password
$badUsername = false;
$badPassword = false;
if($_REQUEST['secureAccess'] == '1') {
  $username = $_REQUEST['username'];
  $password = $_REQUEST['password'];
  if($username == null || $username == '' || strlen($username)<6) $badUsername = true;
  if($password == null || $password == '' || strlen($password)<6) $badPassword = true;
  if($badUsername || $badPassword) {
    $_REQUEST['secureAccess'] = null;
    }
  }
  
// update the user settings
class_settings::updateUserSettings();

// set the setup cookie if mandatory information are present
if(class_settings::$language!='NULL' && class_settings::$currency!='NULL' &&
   class_settings::$language!='' && class_settings::$currency!='') {
  setcookie("setup", true);
  $setupDone = true;
  }
else {
  setcookie("setup", '');
  $setupDone = false;
  }

// switch to the new language if necessary
class_propertyKey::switchToLang(class_settings::$language);

// next action
$action = false;

// HTML to be loaded
$snippet = 'settings';
?>